package cn.hnucm.serchhbservice.controller;


import cn.hnucm.serchhbservice.entity.TbHbBasis;
import cn.hnucm.serchhbservice.entity.TbHbImage;
import cn.hnucm.serchhbservice.service.TbHbImageService;
import cn.hnucm.serchhbservice.utils.Result;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import io.swagger.annotations.Api;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 皇榜图片 前端控制器
 * </p>
 *
 * @author zjl
 * @since 2021-12-09
 */
@Api(tags = "tb_Hb_Image类")
@RestController
@RequestMapping("/serchhbservice/tbHbImage")
public class TbHbImageController {

    @Autowired
    private TbHbImageService tbHbImageService;

    /**
     * 路径： /serchhbservice/tbHbImage/getHbImage/1
     * 描述: 根据hbId查询tb_hb_image表
     *
     * @param hbId 皇榜id
     * @return List<TbHbImage>
     */

    @GetMapping("/getHbImage/{hbId}")
    public List<TbHbImage> getHbImageById(@PathVariable("hbId") int hbId) {
        QueryWrapper<TbHbImage> tbHbImageQueryWrapper = new QueryWrapper<>();
        tbHbImageQueryWrapper.eq("hbId", hbId);
        return tbHbImageService.list(tbHbImageQueryWrapper);
    }

    /**
     * 路径： /serchhbservice/tbHbImage/addHbImage
     * 描述: 向tb_hb_image表添加HbImage
     *
     * @param tbHbImage 皇榜图片
     * @return boolean
     */

    @PostMapping("/addHbImage")
    public boolean addHbImage(@RequestBody TbHbImage tbHbImage) {
        return tbHbImageService.save(tbHbImage);
    }

    /**
     * 路径： /serchhbservice/tbHbImage/updateHbImage
     * 描述: 根据hbId更新tb_hb_image表的数据
     *
     * @param tbHbImage 皇榜图片
     * @return boolean
     */

    @PostMapping("/updateHbImage")
    public boolean updateHbImage(@RequestBody TbHbImage tbHbImage) {
        return tbHbImageService.updateById(tbHbImage);
    }

    /**
     * 路径： /serchhbservice/tbHbImage/deleteHbImage
     * 描述: 根据hbId删除tb_hb_image表的数据
     *
     * @param tbHbImage 皇榜图片
     * @return boolean
     */

    @PostMapping("/deleteHbImage")
    public boolean deleteHbImage(@RequestBody TbHbImage tbHbImage) {
        return tbHbImageService.removeById(tbHbImage.getHbId());
    }
}

